package com.iot.platform.mvc.thing.service.impl;

import java.util.List;

import com.alibaba.fastjson.JSONObject;
import com.iot.common.core.util.R;
import com.iot.platform.common.model.ThingModelProperty;
import com.iot.platform.mvc.thing.service.ThingModelService;
import com.jfinal.kit.StrKit;

public class ThingModelServiceImpl implements ThingModelService {

	@Override
	public R<Boolean> createThingModel(String productId, String thingModelJson) throws Exception {

		if (StrKit.isBlank(productId) || StrKit.isBlank(thingModelJson)) {
			R.failed("参数必填！");
		}

		JSONObject thingModel = JSONObject.parseObject(thingModelJson);
		if (thingModel.containsKey("properties")) {
			List<ThingModelProperty> properties=JSONObject.parseArray(thingModel.getString("properties"), ThingModelProperty.class);
			if(properties!=null && properties.size()>0) {
				for(ThingModelProperty property:properties) {
					
				}
			}

		}

		if (thingModel.containsKey("services")) {

		}

		if (thingModel.containsKey("events")) {

		}

		return null;
	}

}
